// pages/search/search.js
var searchUrl = "https://m.douban.com/rexxar/api/v2/search?q=";
Page({
  data: {
    items: [],
  },
  search({ detail }) {
    var that = this;
    wx.request({
      url: searchUrl + detail.value,
      success({ data }) {
        console.log(data)
        that.setData({
          items: data.subjects.items
        })
      },
      fail() {
        wx.showToast({
          title: '没有该电影名字',
        })
      }
    })
  },

  onLoad: function (options) {
    var that = this;
    wx.request({
      url: searchUrl + options.value,
      success({ data }) {
        console.log(data)
        that.setData({
          items: data.subjects.items
        })
      },
      fail() {
        wx.showToast({
          title: '没有该电影名字',
        })
      }
    })
  },

})